use crate::co;
use crate::comctl::privs::*;
use crate::decl::*;
use crate::msg::*;
use crate::ole::privs::*;
use crate::prelude::*;
use crate::user::privs::*;
pub struct CreateDragImage<'a> {
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for CreateDragImage<'a> {
type RetType = SysResult<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::CREATEDRAGIMAGE.into(),
wparam: 0,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct DeleteItem<'a> {
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for DeleteItem<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::DELETEITEM.into(),
wparam: 0,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct EditLabel<'a> {
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for EditLabel<'a> {
type RetType = SysResult<HWND>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|p| unsafe { HWND::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::EDITLABEL.into(),
wparam: 0,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct EndEditLabelNow {
pub save: bool,
}
unsafe impl MsgSend for EndEditLabelNow {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::ENDEDITLABELNOW.into(),
wparam: !self.save as _,
lparam: 0,
}
}
}
pub struct EnsureVisible<'a> {
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for EnsureVisible<'a> {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::ENSUREVISIBLE.into(),
wparam: 0,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct Expand<'a> {
pub action: co::TVE,
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for Expand<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::EXPAND.into(),
wparam: self.action.raw() as _,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct GetBkColor {}
unsafe impl MsgSend for GetBkColor {
type RetType = Option<COLORREF>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|v| unsafe { COLORREF::from_raw(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETBKCOLOR.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetCount {}
unsafe impl MsgSend for GetCount {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETCOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetEditControl {}
unsafe impl MsgSend for GetEditControl {
type RetType = SysResult<HWND>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|p| unsafe { HWND::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETEDITCONTROL.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetExtendedStyle {}
unsafe impl MsgSend for GetExtendedStyle {
type RetType = co::TVS_EX;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TVS_EX::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETEXTENDEDSTYLE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetImageList {
pub kind: co::TVSIL,
}
unsafe impl MsgSend for GetImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETIMAGELIST.into(),
wparam: self.kind.raw() as _,
lparam: 0,
}
}
}
pub struct GetIndent {}
unsafe impl MsgSend for GetIndent {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETINDENT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetInsertMarkColor {}
unsafe impl MsgSend for GetInsertMarkColor {
type RetType = COLORREF;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETINSERTMARKCOLOR.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetISearchString<'a> {
pub buf: &'a mut WString,
}
unsafe impl<'a> MsgSend for GetISearchString<'a> {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETISEARCHSTRING.into(),
wparam: 0,
lparam: unsafe { self.buf.as_mut_ptr() } as _,
}
}
}
pub struct GetItem<'a, 'b> {
pub tvitem: &'b mut TVITEMEX<'a>,
}
unsafe impl<'a, 'b> MsgSend for GetItem<'a, 'b> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETITEM.into(),
wparam: 0,
lparam: self.tvitem as *mut _ as _,
}
}
}
pub struct GetItemHeight {}
unsafe impl MsgSend for GetItemHeight {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETITEMHEIGHT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetItemRect<'a> {
pub text_only: bool,
pub rect: &'a mut RECT,
}
unsafe impl<'a> MsgSend for GetItemRect<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETITEMRECT.into(),
wparam: self.text_only as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct GetItemState<'a> {
pub hitem: &'a HTREEITEM,
pub mask: co::TVIS,
}
unsafe impl<'a> MsgSend for GetItemState<'a> {
type RetType = co::TVIS;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TVIS::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETITEMSTATE.into(),
wparam: self.hitem.ptr() as _,
lparam: self.mask.raw() as _,
}
}
}
pub struct GetLineColor {}
unsafe impl MsgSend for GetLineColor {
type RetType = Option<COLORREF>;
fn convert_ret(&self, v: isize) -> Self::RetType {
match v as u32 {
CLR_DEFAULT => None,
c => Some(unsafe { COLORREF::from_raw(c) })
}
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETLINECOLOR.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetNextItem<'a> {
pub relationship: co::TVGN,
pub hitem: Option<&'a HTREEITEM>,
}
unsafe impl<'a> MsgSend for GetNextItem<'a> {
type RetType = Option<HTREEITEM>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HTREEITEM::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETNEXTITEM.into(),
wparam: self.relationship.raw() as _,
lparam: self.hitem.map_or(0, |h| h.ptr() as _),
}
}
}
pub struct GetScrollTime {}
unsafe impl MsgSend for GetScrollTime {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETSCROLLTIME.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetTextColor {}
unsafe impl MsgSend for GetTextColor {
type RetType = Option<COLORREF>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|v| unsafe { COLORREF::from_raw(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETTEXTCOLOR.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetTooltips {}
unsafe impl MsgSend for GetTooltips {
type RetType = Option<HWND>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HWND::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETTOOLTIPS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetUnicodeFormat {}
unsafe impl MsgSend for GetUnicodeFormat {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETUNICODEFORMAT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetVisibleCount {}
unsafe impl MsgSend for GetVisibleCount {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::GETVISIBLECOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct HitTest<'a> {
pub info: &'a TVHITTESTINFO,
}
unsafe impl<'a> MsgSend for HitTest<'a> {
type RetType = Option<HTREEITEM>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HTREEITEM::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::HITTEST.into(),
wparam: 0,
lparam: &mut self.info as *mut _ as _,
}
}
}
pub struct InsertItem<'a, 'b> {
pub item: &'b TVINSERTSTRUCT<'a>,
}
unsafe impl<'a, 'b> MsgSend for InsertItem<'a, 'b> {
type RetType = SysResult<HTREEITEM>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|p| unsafe { HTREEITEM::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::INSERTITEM.into(),
wparam: 0,
lparam: self.item as *const _ as _,
}
}
}
pub struct MapAccIdToHtreeitem {
pub acc_id: u32,
}
unsafe impl MsgSend for MapAccIdToHtreeitem {
type RetType = SysResult<HTREEITEM>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|p| unsafe { HTREEITEM::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::MAPACCIDTOHTREEITEM.into(),
wparam: self.acc_id as _,
lparam: 0,
}
}
}
pub struct MapHtreeitemToAccId<'a> {
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for MapHtreeitemToAccId<'a> {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::MAPHTREEITEMTOACCID.into(),
wparam: self.hitem.ptr() as _,
lparam: 0,
}
}
}
pub struct SelectItem<'a> {
pub action: co::TVGN,
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for SelectItem<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SELECTITEM.into(),
wparam: self.action.raw() as _,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct SetAutoScrollInfo {
pub pixels_per_second: u32,
pub redraw_interval: u32,
}
unsafe impl MsgSend for SetAutoScrollInfo {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETAUTOSCROLLINFO.into(),
wparam: self.pixels_per_second as _,
lparam: self.redraw_interval as _,
}
}
}
pub struct SetBkColor {
pub color: Option<COLORREF>,
}
unsafe impl MsgSend for SetBkColor {
type RetType = Option<COLORREF>;
fn convert_ret(&self, v: isize) -> Self::RetType {
match v {
-1 => None,
v => Some(unsafe { COLORREF::from_raw(v as _) }),
}
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETBKCOLOR.into(),
wparam: 0,
lparam: self.color.map_or(-1, |color| u32::from(color) as _),
}
}
}
pub struct SetBorder {
pub action: co::TVSBF,
pub left: u16,
pub top: u16,
}
unsafe impl MsgSend for SetBorder {
type RetType = (u16, u16);
fn convert_ret(&self, v: isize) -> Self::RetType {
(LOWORD(v as _), HIWORD(v as _))
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETBORDER.into(),
wparam: self.action.raw() as _,
lparam: MAKEDWORD(self.left, self.top) as _,
}
}
}
pub struct SetExtendedStyle {
pub style: co::TVS_EX,
pub mask: co::TVS_EX,
}
unsafe impl MsgSend for SetExtendedStyle {
type RetType = HrResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
ok_to_hrresult(v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETEXTENDEDSTYLE.into(),
wparam: self.style.raw() as _,
lparam: self.mask.raw() as _,
}
}
}
pub struct SetHot<'a> {
pub hitem: Option<&'a HTREEITEM>,
}
unsafe impl<'a> MsgSend for SetHot<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETHOT.into(),
wparam: 0,
lparam: self.hitem.map_or(0, |h| h.ptr() as _),
}
}
}
pub struct SetImageList {
pub kind: co::TVSIL,
pub himagelist: Option<HIMAGELIST>,
}
unsafe impl MsgSend for SetImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETIMAGELIST.into(),
wparam: self.kind.raw() as _,
lparam: self.himagelist.as_ref().map_or(0, |h| h.ptr() as _),
}
}
}
pub struct SetIndent {
pub width: u32,
}
unsafe impl MsgSend for SetIndent {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETINDENT.into(),
wparam: self.width as _,
lparam: 0,
}
}
}
pub struct SetInsertMark<'a> {
pub insert_after: bool,
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for SetInsertMark<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETINSERTMARK.into(),
wparam: self.insert_after as _,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct SetInsertMarkColor {
pub color: COLORREF,
}
unsafe impl MsgSend for SetInsertMarkColor {
type RetType = COLORREF;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETINSERTMARKCOLOR.into(),
wparam: 0,
lparam: u32::from(self.color) as _,
}
}
}
pub struct SetItem<'a, 'b> {
pub tvitem: &'b TVITEMEX<'a>,
}
unsafe impl<'a, 'b> MsgSend for SetItem<'a, 'b> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETITEM.into(),
wparam: 0,
lparam: self.tvitem as *const _ as _,
}
}
}
pub struct SetItemHeight {
pub height: Option<u32>,
}
unsafe impl MsgSend for SetItemHeight {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETITEMHEIGHT.into(),
wparam: self.height.map_or(-1, |h| h as _) as _,
lparam: 0,
}
}
}
pub struct SetLineColor {
pub color: Option<COLORREF>,
}
unsafe impl MsgSend for SetLineColor {
type RetType = COLORREF;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETLINECOLOR.into(),
wparam: 0,
lparam: self.color.map_or(CLR_DEFAULT, |c| c.into()) as _,
}
}
}
pub struct SetScrollTime {
pub time_ms: u32,
}
unsafe impl MsgSend for SetScrollTime {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETSCROLLTIME.into(),
wparam: self.time_ms as _,
lparam: 0,
}
}
}
pub struct SetTextColor {
pub color: Option<COLORREF>,
}
unsafe impl MsgSend for SetTextColor {
type RetType = Option<COLORREF>;
fn convert_ret(&self, v: isize) -> Self::RetType {
match v {
-1 => None,
v => Some(unsafe { COLORREF::from_raw(v as _) }),
}
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETTEXTCOLOR.into(),
wparam: 0,
lparam: self.color.map_or(-1, |color| u32::from(color) as _),
}
}
}
pub struct SetTooltips<'a> {
pub htooltips: Option<&'a HWND>,
}
unsafe impl<'a> MsgSend for SetTooltips<'a> {
type RetType = Option<HWND>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HWND::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETTOOLTIPS.into(),
wparam: self.htooltips.map_or(0, |h| h.ptr() as _),
lparam: 0,
}
}
}
pub struct SetUnicodeFormat {
pub use_unicode: bool,
}
unsafe impl MsgSend for SetUnicodeFormat {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SETUNICODEFORMAT.into(),
wparam: self.use_unicode as _,
lparam: 0,
}
}
}
pub struct ShowInfoTip<'a> {
pub hitem: &'a HTREEITEM,
}
unsafe impl<'a> MsgSend for ShowInfoTip<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SHOWINFOTIP.into(),
wparam: 0,
lparam: self.hitem.ptr() as _,
}
}
}
pub struct SortChildren {
pub recursive: bool,
}
unsafe impl MsgSend for SortChildren {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SORTCHILDREN.into(),
wparam: self.recursive as _,
lparam: 0,
}
}
}
pub struct SortChildrenCb<'a> {
pub info: &'a TVSORTCB,
}
unsafe impl<'a> MsgSend for SortChildrenCb<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TVM::SORTCHILDRENCB.into(),
wparam: 0,
lparam: self.info as *const _ as _,
}
}
}